//
//  HWBookPassTimeCell.m
//  嗨文
//
//  Created by 响当当 on 2019/2/25.
//  Copyright © 2019年 dongzheng. All rights reserved.
//

#import "HWBookPassTimeCell.h"

@interface HWBookPassTimeCell()
@property (nonatomic, strong)UILabel *titleLabel;//标题
@property (nonatomic, strong)UILabel *timeLabel;//时间
@property (nonatomic, strong)UILabel *creatTimeLabel;//创建时间
@end

@implementation HWBookPassTimeCell

- (UILabel *)titleLabel
{
    if (!_titleLabel)
    {
        _titleLabel = [HWUtilties creatLabelWithFrame:CGRectMake(18*kUIScaleBasePlus,8*kUIScaleBasePlus,0,16*kUIScaleBasePlus)
                                         textAligment:NSTextAlignmentLeft
                                             textClor:LCHexColor(0x161616)
                                             textFont:16*kUIScaleBasePlus];
    }
    return _titleLabel;
}

- (UILabel *)creatTimeLabel
{
    if (!_creatTimeLabel)
    {
        _creatTimeLabel = [HWUtilties creatLabelWithFrame:CGRectMake(18*kUIScaleBasePlus,CGRectGetMaxY(self.timeLabel.frame),0,16*kUIScaleBasePlus)
                                         textAligment:NSTextAlignmentLeft
                                             textClor:LCHexColor(0x161616)
                                             textFont:16*kUIScaleBasePlus];
    }
    return _creatTimeLabel;
}

- (UILabel *)timeLabel
{
    if (!_timeLabel)
    {
        _timeLabel = [HWUtilties creatLabelWithFrame:CGRectMake(0,20*kUIScaleBasePlus,0,12*kUIScaleBasePlus)
                                         textAligment:NSTextAlignmentLeft
                                             textClor:JSAMainColor
                                             textFont:12*kUIScaleBasePlus];
    }
    return _timeLabel;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.creatTimeLabel];
        [self.contentView addSubview:self.timeLabel];
        
        UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(15*kUIScaleBasePlus,59*kUIScaleBasePlus,345*kUIScaleBasePlus,1*kUIScaleBasePlus)];
        lineView.backgroundColor = LCHexColor(0xEBE5E1);
        [self.contentView addSubview:lineView];
    }
    
    return self;
}

#pragma mark - 获取数据
- (void)getDate:(HWBookPassTimeModel *)model
{
    self.titleLabel.text = [NSString stringWithFormat:@"%@书券",model.totalNum];
    [self.titleLabel sizeToFit];
    
    
    self.creatTimeLabel.text = [HWUtilties getTime:model.createTime];
    [self.creatTimeLabel sizeToFit];
    
    self.timeLabel.text = [NSString stringWithFormat:@"%@天后过期",model.validDays];
    [self.timeLabel sizeToFit];
    [self.timeLabel setX:SCREEN_WIDTH-16*kUIScaleBasePlus-self.timeLabel.frame.size.width];
}

@end
